//
//  MusicRootViewController.m
//  ManSavour
//
//  Created by dllo on 15/10/6.
//  Copyright (c) 2015年 刘志强. All rights reserved.
//

#import "MusicRootViewController.h"
#import "MusicErchoViewController.h"
#import "MusicMineViewController.h"
#import "MusicPlayerViewController.h"


@interface MusicRootViewController ()

@property (nonatomic,retain)MusicErchoViewController *erch;
@property (nonatomic,retain)MusicMineViewController *diantai;


@end

@implementation MusicRootViewController




- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
   

    
    UISegmentedControl *sage = [[UISegmentedControl alloc]initWithItems:[NSArray arrayWithObjects:@"在线音乐",@"我的音乐", nil]];
    sage.selectedSegmentIndex = 0;
    
    [sage initWithRect:140 andY:10 andWidth:80 andheight:20];
    [sage addTarget:self action:@selector(sageAvtion:)   forControlEvents:(UIControlEventValueChanged)];
    self.navigationItem.titleView = sage;
    
    
  
    
    //将Root 作为两个页面的试图控制器
    
    self.erch = [[MusicErchoViewController alloc]init];
    self.diantai = [[MusicMineViewController alloc]init];
    
    [self addChildViewController:self.erch];
    [self addChildViewController:self.diantai];
    
    [self.view addSubview:self.diantai.view];
    [self.view addSubview:self.erch.view];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"Music" style:(UIBarButtonItemStyleDone) target:self action:@selector(barAction)];
    
}


- (void)barAction
{
    MusicPlayerViewController *play=[MusicPlayerViewController sharePlayerDataHandel];
    [self.navigationController pushViewController:play animated:YES];
}


- (void)sageAvtion:(UISegmentedControl *)sage
{
    if (sage.selectedSegmentIndex == 0) {
        [self.view bringSubviewToFront:self.erch.view];
    }
    else
    {
        [self.view bringSubviewToFront:self.diantai.view];
    }
}







- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
